The Definitive Guide to DAX (Business Skills) by Russo Marco & Ferrari Alberto
Author:Russo, Marco & Ferrari, Alberto [Russo, Marco]
Language: eng
Format: azw3
Publisher: Pearson Education
Published: 2019-07-01T16:00:00+00:00
The result of EXCEPT filters the Customer[CountryRegion] column because it is the column used by the table taken as the first argument of EXCEPT.
Using tables as filters
Functions manipulating tables are oftentimes used to build complex filters for CALCULATE parameters. In this section, we provide further examples, always leading you one step further in your understanding of DAX.
Implementing OR conditions
A first example where manipulating tables proves to be a useful skill is the following. Imagine having to implement an OR condition between the selections made in different slicers, instead of the default AND behavior provided by client tools like Excel and Power BI.
The report in Figure 12-14 contains two slicers. The default behavior of Power BI is to intersect the two conditions. As a consequence, the numbers shown represent the sales of Home Appliances to customers with a High School education.
Figure 12-14 By default, slicer conditions are intersected so that all the conditions are applied together. Instead of intersecting the two conditions, one might want to merge them. In other words, the numbers shown in the report need to be the sales of products sold to customers with a High School education or the sales of Home Appliances. Because Power BI does not support “or” conditions between slicers, one can solve the problem by using DAX.
Remember that each cell of the report has a filter context containing both a filter on the category and a filter on the education. Both filters need to be replaced. There are several possible solutions to the same pattern; we demonstrate the use of three different formulas.
The first, and probably the easiest expression of that filter, is the following:
Click here to view code image
OR 1 := VAR CategoriesEducations = CROSSJOIN ( ALL ( 'Product'[Category] ), ALL ( Customer[Education] ) ) VAR CategoriesEducationsSelected = FILTER ( CategoriesEducations, OR ( 'Product'[Category] IN VALUES ( 'Product'[Category] ), Customer[Education] IN VALUES ( Customer[Education] ) ) ) VAR Result = CALCULATE ( [Sales Amount], CategoriesEducationsSelected ) RETURN Result
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
NET | C & C++ Windows Programming |
SQL Server | VBA |
Visual Basic |
Deep Learning with Python by François Chollet(12593)
Hello! Python by Anthony Briggs(9928)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9804)
The Mikado Method by Ola Ellnestam Daniel Brolund(9787)
Dependency Injection in .NET by Mark Seemann(9348)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8310)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7772)
Grails in Action by Glen Smith Peter Ledbrook(7705)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7567)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7187)
Microservices with Go by Alexander Shuiskov(6951)
Practical Design Patterns for Java Developers by Miroslav Wengner(6870)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6813)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6426)
Angular Projects - Third Edition by Aristeidis Bampakos(6231)
The Art of Crafting User Stories by The Art of Crafting User Stories(5746)
NetSuite for Consultants - Second Edition by Peter Ries(5674)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5490)
Kotlin in Action by Dmitry Jemerov(5075)
